package com.wf.secure.process;


import com.wf.utils.ServletUtil;
import com.wf.web.domain.Result;
import com.wf.web.domain.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Security 用户暂无权限处理类
 * author: mpk
 * */
@Component
@Slf4j
public class SecureNoPermissionHandler implements AccessDeniedHandler{

    @Override
    public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException e) throws IOException {

        log.info("用户暂无权限处理类");
        ServletUtil.writeJson(Result.failure(ResultCode.NOT_PERMISSION));
    }
}
